﻿using _2008A.PH5._0221_0317.FuXi.EFCore;
using _2008A.PH5._0221_0317.FuXi.IRespository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _2008A.PH5._0221_0317.FuXi.Respository
{
    public class BaseRespository<T> : IBaseRespository<T> where T : class, new()
    {
        FuXiDbContext _context;

        public BaseRespository(FuXiDbContext context)
        {
            _context = context;
        }

        public void Delete(List<T> ts)
        {
            _context.Set<T>().RemoveRange(ts);
        }

        public void Insert(T t)
        {
            _context.Set<T>().Add(t);
        }

        public IQueryable<T> Query()
        {
            return _context.Set<T>().AsQueryable();
        }

        public void Update(T t)
        {
            _context.Set<T>().Update(t);
        }
    }
}
